<template>
  <div class="photo-info">
    <van-panel :title="imageInfo.title"  :status="'阅读'+imageInfo.click+'次'">
      <div class="box-img">
        <img v-for="(item,index) in thums" :key="item.id" v-lazy="item.src" alt="" @click="showImage(index)">
      </div>
      <div>{{imageInfo.content}}</div>
    </van-panel>
    <comments :id="id"></comments>
  </div>
</template>

<script>
import { ImagePreview } from 'vant'
import comments from "../../components/comments"
export default {
  props:['id'],
  components:{
    comments
  },
  data () {
    return {
      thums:[],
      imageInfo:{}
    }
  },
  created () {
    this.getThumImages()
    this.getimageInfo()
  },
  methods:{
    async getThumImages () {
      const res = await this.$http.getThumImages(this.id)
      this.thums = res.data.message
      console.log(this.thums)
    },
    async getimageInfo () {
      const res = await this.$http.getimageInfo(this.id)
      this.imageInfo = res.data.message
      console.log(this.imageInfo)
    },
    showImage (startPosition) {
      const images = []
      this.thums.forEach(item => images.push(item.src))
      ImagePreview({
        images,
        startPosition
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.photo-info{
  padding: 10px;
  .van-cell__title{
    font-size: 18px;
    font-weight: 600;
  }
  .van-panel__content{
    font-size: 12px;
    padding: 10px;
    text-indent: 2em;
  }
  .box-img{
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    img{
      width: 105px;
      height: 100px;
    }
  }
}
</style>
